package com.engine4cloud.tdf.supervision.controller.web;

import com.engine4cloud.tdf.common.core.util.R;
import com.engine4cloud.tdf.common.data.web.response.PageInfo;
import com.engine4cloud.tdf.common.data.web.response.Params;
import com.engine4cloud.tdf.supervision.dto.result.*;
import com.engine4cloud.tdf.supervision.dto.result.*;
import com.engine4cloud.tdf.supervision.service.HomeIndexService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 首页-web
 *
 * @author wenjie
 * @date 2024-05-13 14:33:54
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/web/home/index")
@Tag(description = "HomeIndex", name = "首页-web")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class HomeIndexWebController {

    @Resource
    private HomeIndexService homeIndexService;

    /**
     * 矫正对象-数量
     *
     * @return R<HomeIndexCorrectorResultDTO>
     */
    @Operation(summary = "矫正对象-数量", description = "矫正对象-数量")
    @GetMapping("/corrector/count")
    public R<HomeIndexCorrectorResultDTO> count() {
        return R.ok(homeIndexService.count());
    }

    /**
     * 待办任务分页-查询
     *
     * @return R<PageInfo < HomeIndexSpResultDTO>>
     */
    @Operation(summary = "待办任务分页-查询", description = "待办任务分页-查询")
    @GetMapping("/task/page")
    public R<PageInfo<HomeIndexSpResultDTO>> taskPage(@ParameterObject Params page) {
        return R.ok(homeIndexService.taskPage(page));
    }

    /**
     * 任务数量-统计
     *
     * @return R<HomeIndexTaskResultDTO>
     */
    @Operation(summary = "任务数量-统计", description = "任务数量-统计")
    @GetMapping("/task/count")
    public R<HomeIndexTaskResultDTO> taskCount() {
        return R.ok(homeIndexService.taskCount());
    }

    /**
     * 矫正对象-性别比例
     *
     * @return R<HomeIndexCorrectorSexRateResultDTO>
     */
    @Operation(summary = "矫正对象-性别比例", description = "矫正对象-性别比例")
    @GetMapping("/sex/rate")
    public R<List<HomeIndexCorrectorSexRateResultDTO>> sexRate() {
        return R.ok(homeIndexService.sexRate());
    }

    /**
     * 矫正对象-犯罪类型
     *
     * @return R<HomeIndexCrimeCategoryResultDTO>
     */
    @Operation(summary = "矫正对象-犯罪类型", description = "矫正对象-犯罪类型")
    @GetMapping("/crime/category")
    public R<List<HomeIndexCrimeCategoryResultDTO>> crimeCategory() {
        return R.ok(homeIndexService.crimeCategory());
    }

    /**
     * 矫正对象-年龄段
     *
     * @return R<HomeIndexAgeRangeResultDTO>
     */
    @Operation(summary = "矫正对象-年龄段", description = "矫正对象-年龄段")
    @GetMapping("/age/range")
    public R<List<HomeIndexAgeRangeResultDTO>> ageRange() {
        return R.ok(homeIndexService.ageRange());
    }
}
